<!-- <template>
    <el-menu class="el-menu-demo" mode="horizontal" @select="click" :default-active="activeIndex" style="margin-bottom: 20px">
        <div v-for="(item, index) in menu" :key="index" style="display: inline-block; float: left;">
            <el-menu-item :index="item.name"  v-if="item.children.length == 0">
                <i v-if="item.icon" :class="item.icon"></i>
                {{item.title}}
            </el-menu-item>
            <el-submenu :index="item.name" v-else>
                <template slot="title">
                    <i v-if="item.icon" :class="item.icon"></i>
                    {{item.title}}
                </template>
                <el-menu-item v-for="(i,s) in item.children" :key="s" :index="i.name">{{i.title}}</el-menu-item>
            </el-submenu>
        </div>
    </el-menu>
</template>

<script>
    import router from '../router'
	import { userInfo } from '../../server/index.js';
    export default {
        name: "CrmHeader",
        data() {
            return {}
        },
        computed: {
            menu() {
                var menu = []
                var data = router
                for (var t in data) {
                    for (var i in data[t]['children']) {
                        if(data[t]['children'][i].menu) menu.push({
                            title: data[t]['children'][i].title || '',
                            name: data[t]['children'][i].name || '',
                            icon: data[t]['children'][i].icon || '',
                            width: data[t]['children'][i].width || '',
                            children: data[t]['children'][i].children || []
                        })
                    }
                }
                // console.log(menu)
                return menu
            },
            activeIndex() {
                if (this.$route.matched[2]) {
                    return this.$route.matched[2].name || ''
                } else {
                    return ''
                }
            }
        },
		mounted() {
		},
        methods: {
            click(index) {
                this.$router.push(
                    {
                        name: index
                    }
                )
            },
        },
        created() {
        },
        watch: {}
    }
</script>

<style scoped>

</style> -->